package com.awesome.imagedemo.bitmap;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PorterDuff;

import androidx.annotation.NonNull;

import com.awesome.imagedemo.R;
import com.awesome.imagedemo.app.App;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;

import org.jetbrains.annotations.NotNull;

import java.security.MessageDigest;

/**
 * Author: zhangjingfang
 * Email:zhangjingfang@jeejio.com
 * Date: 2021/12/3
 * Description:类描述
 */
public class CustomBitmapTransformation extends BitmapTransformation {
    private Bitmap srcBitmap = BitmapFactory.decodeResource(App.getInstance().getResources(), R.mipmap.head_img_mask);

    private PorterDuff.Mode mode;

    public CustomBitmapTransformation(PorterDuff.Mode mode) {
        this.mode = mode;
    }

    @Override
    protected Bitmap transform(@NonNull @NotNull BitmapPool pool, @NonNull @NotNull Bitmap toTransform, int outWidth, int outHeight) {
        return BitmapUtil.getBimapForXfermode(srcBitmap, toTransform, mode);
    }

    @Override
    public void updateDiskCacheKey(@NonNull @NotNull MessageDigest messageDigest) {

    }
}
 
 